package cn.chiship.sdk.core.useragent;

/**
 * @author lijian
 */
public class SequentialVersionFetcher implements VersionFetcher {

	private final VersionFetcher[] fetchers;

	public SequentialVersionFetcher(VersionFetcher first, VersionFetcher... others) {
		this.fetchers = new VersionFetcher[others.length + 1];
		this.fetchers[0] = first;
		for (int i = 0; i < others.length; i++) {
			this.fetchers[i + 1] = others[i];
		}
	}

	@Override
	public Version version(String str) {
		for (VersionFetcher fetcher : this.fetchers) {
			Version version = fetcher.version(str);
			if (version != null) {
				return version;
			}
		}
		return null;
	}

}
